//! HTTP request step implementation

use crate::error::Result;
use crate::models::{
    config::StepConfig,
    step::{IStep, StepType, StepResult, StepContext},
    request::HttpRequest,
};
use async_trait::async_trait;
use uuid::Uuid;

/// HTTP request step
#[derive(Debug, Clone)]
pub struct RequestStep {
    id: Uuid,
    config: StepConfig,
    request: HttpRequest,
}

impl RequestStep {
    pub fn new(config: StepConfig, request: HttpRequest) -> Self {
        Self {
            id: Uuid::new_v4(),
            config,
            request,
        }
    }
}

#[async_trait]
impl IStep for RequestStep {
    fn name(&self) -> &str {
        &self.config.step_name
    }
    
    fn step_type(&self) -> StepType {
        StepType::Request
    }
    
    fn config(&self) -> &StepConfig {
        &self.config
    }
    
    fn config_mut(&mut self) -> &mut StepConfig {
        &mut self.config
    }
    
    async fn execute(&self, context: &mut StepContext) -> Result<StepResult> {
        // TODO: Implement HTTP request execution
        let step_result = StepResult::new(self.id, self.name().to_string(), self.step_type());
        Ok(step_result.failure("Request step not yet implemented".to_string()))
    }
    
    fn id(&self) -> Uuid {
        self.id
    }
    
    fn clone_step(&self) -> Box<dyn IStep> {
        Box::new(self.clone())
    }
}
